package cn.itcast.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class RuntimeMonitorAspect {
    @Around("execution(* cn.itcast..*.*(..))")
    public Object around(ProceedingJoinPoint pjp)throws Throwable{
        String className = pjp.getSignature().getDeclaringTypeName();
        int methodName = pjp.getSignature().getModifiers();
        long startTime = System.currentTimeMillis();
        Object result = pjp.proceed(pjp.getArgs());
        long endTime = System.currentTimeMillis();
        System.out.println(className+"."+methodName+"执行了"+(endTime-startTime)+"毫秒");
        return result;
    }

}
